export async function downloadImgByUrl(fileUrl: string) {
  return new Promise(resolve=> {
    try {
      const img = new Image();
      img.setAttribute('crossOrigin', 'anonymous') //关键
      img.onload = ()=> {
        // 创建Canvas元素
        const canvas = document.createElement('canvas');
        canvas.width = img.naturalWidth;
        canvas.height = img.naturalHeight;

        // 绘制图片到Canvas
        const ctx = canvas.getContext('2d');
        ctx.drawImage(img, 0, 0);

        // 将Canvas内容转为Blob
        return canvas.toBlob(function(blob) {
          resolve(new File(blob));
        }, 'image/png');
      }
      img.src = fileUrl;
    } catch (e) {
      resolve(null);
    }
  })
}
